#include "StandardCalibration.h"

StandardCalibration::StandardCalibration(QObject *parent) :
    Count(parent), calibrateCount(0), calibrateValid(false), calibrateCompelete(false)
{
}

void StandardCalibration::doInit()
{
    //初始化页面参数
    viewDataInit();
    //使能吸样键
    setEnable(true);
}

void StandardCalibration::doUnInit()
{


}

void StandardCalibration::viewDataInit()
{
    mStandardCalibViewModel.BatchNumber = "";
    mStandardCalibViewModel.ExpirationDate = "";
    mStandardCalibViewModel.analysisMode = Count::WHOLD_BLOOD;
    mStandardCalibViewModel.bloodMode = Count::CBCDIFF;

    for(int i = 0; i < STANDARD_CALIBRATE_COUNT; i++)
    {
        mStandardCalibViewModel.param[i].wbc = 0;
        mStandardCalibViewModel.param[i].hgb = 0;
        mStandardCalibViewModel.param[i].mcv = 0;
        mStandardCalibViewModel.param[i].rbc = 0;
        mStandardCalibViewModel.param[i].plt = 0;
    }

    mStandardCalibViewModel.target.wbc = 0;
    mStandardCalibViewModel.target.hgb = 0;
    mStandardCalibViewModel.target.mcv = 0;
    mStandardCalibViewModel.target.plt = 0;
    mStandardCalibViewModel.target.rbc = 0;
}

void StandardCalibration::setData(QVariant data)
{
    if(data.canConvert<StandardCalibViewModel>())
    {
        StandardCalibViewModel vModel = data.fromValue<StandardCalibViewModel>(data);

        if(mStandardCalibViewModel.BatchNumber != vModel.BatchNumber)
        {
            calibrateInit();
        }

        mBloodType = vModel.bloodMode;
        mStandardCalibViewModel.BatchNumber = vModel.BatchNumber;
    }
}

void StandardCalibration::setCountResult(const CountResultDao &countResult)
{
}

bool StandardCalibration::paramCheck()
{
}

bool StandardCalibration::calibrationCompeleted()
{
    return calibrateCompelete;
}

bool StandardCalibration::calibrationValid()
{
    return calibrateValid;
}

void StandardCalibration::calibrateResultSave()
{
}

void StandardCalibration::calibrateInit()
{
    for(int i = 0; i < STANDARD_CALIBRATE_COUNT;i++)
    {
        calibBuffer[i].hgb = 0;
        calibBuffer[i].mcv = 0;
        calibBuffer[i].plt = 0;
        calibBuffer[i].rbc = 0;
        calibBuffer[i].wbc = 0;
    }

    calibrateCount = 0;
    calibrateCompelete = false;
    calibrateValid = false;
}

void StandardCalibration::calculate()
{
}
